package com.jappit.runtracker.screens;

import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import com.jappit.runtracker.utils.AppUtils;

public class SplashScreen extends Canvas
{

	protected void paint(Graphics graphics)
	{
		graphics.setColor(0xffffff);
		graphics.drawRect(0, 0, getWidth(), getHeight());
		
		
		try
		{
			Image splash = Image.createImage("/splashIcon128.png");
			graphics.drawImage(splash, getWidth() / 2, getHeight() / 2, Graphics.HCENTER | Graphics.VCENTER);
			
			Timer dismissTimer = new Timer();
			dismissTimer.schedule(new TimerTask() {
				public void run() {
					AppUtils.getInstance().gotoScreen(new RunListScreen());
				}
			}, 2000);
		}
		catch(Exception e)
		{
			e.printStackTrace();
			
			AppUtils.getInstance().gotoScreen(new RunListScreen());
		}
	}
}
